﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Zero.BLL;
using Zero.Code;
using Zero.Model;

namespace Zero.Framework.Areas.SystemManage.Controllers
{
    public class DutyController : Controller
    {
        // GET: SystemManage/Duty
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Form()
        {
            return View();
        }

        public ActionResult Details()
        {
            return View();
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public string GetDutyList()
        {
            int roleId = OperatorProvider.Provider.GetCurrentNoEncrypt().RoleId.ToInt();//获取当前用户角色ID
            return Code.Json.ToJson(new BLL.RoleAuthorization().GetDutyByRoleID(roleId));
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(string keyword)
        {
            var data = new BLL.RoleAuthorization().GetDuty(1);
            return Content(Code.Json.ToJson(data));
        }

        /// <summary>
        /// 获取需要在表单中显示的岗位机构
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [HandlerAjaxOnly]
        public string GetFormJson(string keyValue)
        {
            return Code.Json.ToJson(new BLL.RoleAuthorization().GeyDutyById(keyValue.ToInt()));
        }
    }
}